fsck: Only print "marking commit partial" once
authorColin Walters <walters@verbum.org>
Wed, 18 Apr 2018 18:36:19 +0000 (18:36 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 23 Apr 2018 17:23:40 +0000 (17:23 +0000)
Let's only print if the commit isn't already partial; this
addresses a spam of "marking commit partial" from fsck.

Closes: #1548
Approved by: cgwalters

src/ostree/ot-builtin-fsck.c
tests/installed/nondestructive/itest-pull.sh
tests/test-corruption.sh

index 8a44b619a9b7fcfb1b4a7358ca0ff1493e2e129a..81124d3f6c31eaa828c1d3fa83c56e0a8edbdc36 100644 (file)
@@ -99,9 +99,16 @@ fsck_one_object (OstreeRepo            *repo,
               for (i = 0; parent_commits[i] != NULL; i++)
                 {
                   const char *parent_commit = parent_commits[i];
-                  g_printerr ("Marking commit %s as partial\n", parent_commit);
-                  if (!ostree_repo_mark_commit_partial (repo, parent_commit, TRUE, error))
+                  OstreeRepoCommitState state;
+                  if (!ostree_repo_load_commit (repo, parent_commit, NULL,
+                                                &state, error))
                     return FALSE;
+                  if ((state & OSTREE_REPO_COMMIT_STATE_PARTIAL) == 0)
+                    {
+                      g_printerr ("Marking commit as partial: %s\n", parent_commit);
+                      if (!ostree_repo_mark_commit_partial (repo, parent_commit, TRUE, error))
+                        return FALSE;
+                    }
                 }
             }
         }
index b3a52a27d37568be801f163313d8330868e16369..0cf0ec75ed827a8725d6fd3074b709a420883109 100755 (executable)
@@ -35,11 +35,12 @@ echo "ok pull"
 # fsck marks commits partial
 # https://github.com/ostreedev/ostree/pull/1533
 for d in $(find bare-repo/objects/ -maxdepth 1 -type d); do
-    (find ${d} -name '*.file' || true) | head -20 | xargs rm -vf
+    (find ${d} -name '*.file' || true) | head -20 | xargs rm -f
 done
-if ostree --repo=bare-repo fsck; then
+if ostree --repo=bare-repo fsck |& tee fsck.txt; then
     fatal "fsck unexpectedly succeeded"
 fi
+assert_streq $(grep -cE -e 'Marking commit as partial' fsck.txt) "1"
 ostree --repo=bare-repo pull origin ${host_nonremoteref}
 # Don't need a full fsck here
 ostree --repo=bare-repo ls origin:${host_nonremoteref} >/dev/null
index 3b4a649eafcc9528be6f5716409bf6fa0ad845db..f26ed2d2676848c34f8b4eaa7532d91e890b941f 100755 (executable)
@@ -105,7 +105,7 @@ if $OSTREE fsck -q 2>err.txt; then
     assert_not_reached "fsck unexpectedly succeeded"
 fi
 assert_file_has_content_literal err.txt "Object missing:"
-assert_file_has_content_literal err.txt "Marking commit $rev as partial"
+assert_file_has_content_literal err.txt "Marking commit as partial: $rev"
 assert_has_file repo/state/${rev}.commitpartial
 
 echo "ok missing file"
@@ -125,7 +125,7 @@ if $OSTREE fsck -q --delete 2>err.txt; then
     assert_not_reached "fsck unexpectedly succeeded"
 fi
 assert_file_has_content_literal err.txt "Corrupted file object;"
-assert_file_has_content_literal err.txt "Marking commit $rev as partial"
+assert_file_has_content_literal err.txt "Marking commit as partial: $rev"
 assert_has_file repo/state/${rev}.commitpartial
 
 echo "ok corrupt file"